Skip to content

Conversation

owjsub
Copy link

@owjsub owjsub commented Oct 6, 2025

Description

Changes the default zIndex of View from 0 to 'auto' to fix z-index layering issues with nested components.

Problem

Setting zIndex: 0 on a positioned element establishes a new local CSS stacking context, which isolates child elements with z-index values inside their parent View. This forces developers to manually add z-index to all nested Views just to make overlapping elements work correctly, as described in #2741.

Solution

By using zIndex: 'auto' instead, View no longer establishes a stacking context by default. This allows nested elements with z-index to participate in the parent stacking context and layer naturally relative to other positioned elements in the document tree, without requiring manual z-index management throughout the component hierarchy.

Changes

  • Changed zIndex from 0 to 'auto' in View's default styles
  • Added test to prevent regression and document the intent

Impact

This is a behavioral change that makes z-index work more intuitively and aligns better with React Native's behavior. Existing apps that don't rely on the stacking context isolation (uncommon) should see no difference. Apps that struggled with z-index layering will now work correctly without workarounds.

Closes #2741

Copy link

codesandbox-ci bot commented Oct 6, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 28d7d4a:

Sandbox Source
react-native-web-examples Configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set zIndex: 'auto' will resolve many Problems

1 participant